import request from '@/utils/request'

export function loginByUsername(code, username, password) {
  const params = {
    code,
    username,
    password
  }
  return request({
    url: '/system/doLogin',
    method: 'post',
    params
  })
}

export function logout() {
  return request({
    url: '/system/logout',
    method: 'post'
  })
}

export function getShowValidateCode(params) {
  return request({
    url: '/system/user/getShowValidateCode',
    method: 'get',
    params
  })
}

export function getValidateCode(phone) {
  return request({
    url: '/system/user/getValidateCode',
    method: 'get',
    params: { phone }
  })
}

export function loginByPhone(phone, password, validateCode) {
  return request({
    url: '/system/doLogin',
    method: 'post',
    params: { phone, password, validateCode }
  })
}

export function loginByPhoneAndSms(phone, smsCode) {
  return request({
    url: '/system/doLogin',
    method: 'post',
    params: { phone, smsCode }
  })
}

export function sendSms(phone, validateCode, type) {
  return request({
    url: '/system/user/doSendSms',
    method: 'post',
    params: { phone, validateCode, type }
  })
}

export function doCheckSmsCode(phone, smsCode, type) {
  return request({
    url: '/system/user/doCheckSmsCode',
    method: 'post',
    params: { phone, smsCode, type }
  })
}

export function doCheckRegSmsCode(phone, smsCode) {
  return request({
    url: '/system/user/doCheckRegSmsCode',
    method: 'post',
    params: { phone, smsCode }
  })
}

export function updatePwdByToken(accessToken, password) {
  return request({
    url: '/system/user/updatePwdByToken',
    method: 'post',
    params: { accessToken, password }
  })
}

export function getConfigByDomain(domain) {
  return request({
    url: '/common/getConfigByDomain.ignore',
    method: 'get',
    params: { domain }
  })
}
